import type {CrudSchema} from '@/hooks/web/useCrudSchemas'
import {dateFormatter} from '@/utils/formatTime'

// 表单校验
export const rules = reactive({
  userId: [required],
  typeId: [required],
  type: [required],
  identifier: [required],
  credential: [required],
})

// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
  {
    label: '序号',
    field: 'index',
    type: 'index',
    isForm: false
  },
  {
    label: '用户昵称',
    field: 'nickName',
  },
  {
    label: '认证类型编码',
    field: 'type',
    isSearch: true,
    search: {
      component: 'Select',
      componentProps:{
        style: 'width: 192px',
      }
    },
    form:{
      component: 'Select',
      componentProps:{
        style: 'width: 192px',
      }
    }
  },
  {
    label: '认证标识',
    field: 'identifier',
    isSearch: true,
  },
  {
    label: '认证凭证',
    field: 'credential',
  },
  {
    label: '创建时间',
    field: 'createTime',
    formatter: dateFormatter,
    isSearch: true,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    isForm: false,
  },
  {
    label: '操作',
    field: 'action',
    isForm: false
  }
])
export const {allSchemas} = useCrudSchemas(crudSchemas)
